package com.ujson.base.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;

@Slf4j
public class SwaggerUtil {
    public static void printSwaggerUrl() {
        Environment env = SpringContextUtil.getBean(Environment.class);
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        String service = env.getProperty("spring.application.name");

        if ("/".equals(path)) {
            path = "";
        }
        log.info("\n----------------------------------------------------------\n\t" +
                service + "服务 is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                "swagger-ui: \thttp://localhost:" + port + path + "/swagger-ui.html\n\t" +
                "actuator: \thttp://localhost:" + port + path + "/actuator/info\n\t" +
                "----------------------------------------------------------");
    }
}
